<#include "../../common/_header.htm">
<div class="systemsjbg">
    <span class="glyphicon glyphicon-remove" aria-hidden="true" onclick="afterUpdateVersion()"></span>
    <div class="newbbcon">
        <div class="findnew">发现新版本</div>
        <div class="newh"></div>
    </div>
    <div class="UpdateContent">
        <p class="UpdateContentt">1、新增自定义功能</p>
        <p class="UpdateContentt">2、修复一些小bug</p>
        <p class="UpdateContentt">3、新增案件功能</p>
    </div>
    <div id="version_up_btn" style="display: none">
        <div class="nowUpdateBtn" onclick="updateVersion()">马上升级</div>
        <div class="lateUpdate" onclick="afterUpdateVersion()">以后再说</div>
    </div>
</div>
<script>
    $(function () {
        getCurrentVersion()
    })
    //得到当前和最新版本号
    function getCurrentVersion() {
        $.ajax({
            type:"GET",
            url:basepath+"/version/getcurrent_version",
            dataType:"json",
            success:function(data){
                if (data.flag) {
                    var localVersion= data.data.current.version_num
                    var remoteVersion= data.data.remote.version_num
                    if (localVersion==remoteVersion) {
                        $(".findnew").html("当前为最新版本")
                        $("#version_up_btn").hide()
                    }else{
                        $("#version_up_btn").show()
                    }
                    $(".newh").html(remoteVersion);
                }
            },
            error:function(jqXHR){
                console.log("Error: 得到当前和最新版本号失败");
            }
        });
    }
    //以后再说
    function afterUpdateVersion() {
        top.dialog({id:"version"}).close()
    }
    //现在升级
    function updateVersion() {
        $(".nowUpdateBtn").html('正在升级...');
        $(".nowUpdateBtn").addClass('disable');
        $.ajax({
            type:"GET",
            url:"/version/upSql",
            dataType:"json",
            success:function(data){
                if (data.flag) {
                    $(".nowUpdateBtn").html('请等待1分钟重新登录...');
                    toastr.info("系统升级完成，请等待一分钟退出重新登录即可","提示信息");
                }else{
                    $(".nowUpdateBtn").html('马上升级');
                    $(".nowUpdateBtn").removeClass('disable');
                    toastr.error("升级失败,本地升级服务没有启动","提示信息");
                }
            },
            error:function(jqXHR){
                toastr.error("升级失败","提示信息");
                console.log("Error: 更新失败");
            }
        });
    }
</script>
<style>
    span.glyphicon.glyphicon-remove {
        top: 60px;
        left: 520px;
        font-size: 15px;
        color: #fff;
        cursor: pointer;
    }
    .disable{
        pointer-events:none;
    }
    .systemsjbg{
        background:url("${ctx}/imgs/xtsjbg.png") no-repeat;
        width: 550px;
        height: 596px;
    }
    body.hold-transition.skin-blue {
        background: transparent;
    }
    .newbbcon {
        padding-top: 62px;
        padding-left: 25px;
    }
    .findnew {
        font-size: 30px;
        font-weight: 550;
        font-stretch: normal;
        letter-spacing: 2px;
        color: #ffffff;
    }
    .newh {
        font-size: 20px;
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 1px;
        color: #ffffff;
    }
    .UpdateContent {
        margin-top: 133px;
        margin-left: 22px;
    }
    p.UpdateContentt {
        margin-bottom: 20px;
        font-size: 16px;
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 0px;
        color: #666666;
    }
    .nowUpdateBtn{
        width: 440px;
        height: 60px;
        background-color: #4288ea;
        border-radius: 33px;
        text-align: center;
        line-height: 60px;
        font-size: 20px;
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 1px;
        color: #ffffff;
        margin: 0 auto;
        margin-top: 70px;
        cursor: pointer;
    }
    .nowUpdateBtn:hover{
        background-color: #3296f1;
    }
    .nowUpdateBtn:active{
        background-color: #0c76d7;
    }
    .lateUpdate{
        font-size: 14px;
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 1px;
        color: #000000;
        opacity: 0.6;
        margin: 0 auto;
        text-align: center;
        margin-top: 10px;
        cursor: pointer;
    }

    .ui-dialog {
        border: none;
        box-shadow: 0 0 8px rgba(0,0,0,.1)!important;
        background: transparent;
    }
</style>
</body>
</html>
